#!/bin/bash

export BASE_DATA_PATH=/home/mixagol/data
export CUR_DATA_DIR=${BASE_DATA_PATH}/2_raw_matrix_nw
export LC_ALL=C

mkdir -p $CUR_DATA_DIR/input_files
zcat ${BASE_DATA_PATH}/2_raw_matrix_blast/results_0.05_sorted.txt.gz | 2_raw_matrix_nw/split_genomes.py $CUR_DATA_DIR/input_files

mkdir -p $CUR_DATA_DIR/output_files

g++ -O3 2_raw_matrix_nw/nw_aligner_batch.cpp -o 2_raw_matrix_nw/nw_aligner_batch

ls $CUR_DATA_DIR/input_files | xargs -n1 -P1 -I {} \
    bash -c "cat $CUR_DATA_DIR/input_files/"{}" \
        | 2_raw_matrix_nw/prepare_data.py -G $BASE_DATA_PATH/1_databases/genom.db -g $BASE_DATA_PATH/1_databases/gen.db \
        | 2_raw_matrix_nw/nw_aligner_batch \
        > $CUR_DATA_DIR/output_files/"{}
